<!doctype html>
<html>
    
    <head>
        <meta charset="UTF-8">
        <meta name="Generator" content="EditPlus®">
        <meta name="Author" content="">
        <meta name="Keywords" content="">
        <meta name="Description" content="">
		<script src="js/jquery-1.10.2.min.js"></script>
        <title>优客服API Demo</title>
		<script language="javascript">
			var authorization ;
			var demo =  {
				login:function(username , password){
					$.post("http://uk.ukewo.cn/tokens" , "username=admin&password=123456" , function(data){
						authorization = data ;
					})
				},
				ajax:function(url , callback){
					$.ajax({
						type: "get",
						url:url , 
						headers:{"authorization":authorization},
						success: function (data) {
							console.log(data);
							alert("token:"+data);
						}
					});

				},
				getUser:function(current){
					demo.ajax("http://uk.ukewo.cn/api/user?username="+current,function(data){
						console.log(data);
						alert(data);
					});
				}
			}
			$(document).ready(function(){
				demo.login();
			});
		</script>
	</head>
    
    <body>
		<a href="javascript:void(0)" onclick="demo.getUser('admin')">获取当前登录用户信息</a>
	</body>

</html>